package br.cin.ufpe.rabbit;

import gov.nasa.jpf.jvm.ThreadInfo;
import gov.nasa.jpf.util.Misc;

public class ThreadInfoPair{

	private ThreadInfo t1;
	private ThreadInfo t2;
	
	public ThreadInfoPair(ThreadInfo t1, ThreadInfo t2){
		setT1(t1);
		setT2(t2);
	}
	
	
	
	 public ThreadInfo getT1() {
  	return t1;
  }

	public void setT1(ThreadInfo t1) {
		if(t1 == null){
			throw new RuntimeException("ThreadInfo t1 couldn't be null");
		}
  	this.t1 = t1;
  }

	public ThreadInfo getT2() {
  	return t2;
  }

  public void setT2(ThreadInfo t2) {
  	if(t2 == null){
			throw new RuntimeException("ThreadInfo t2 couldn't be null");
		}
  	this.t2 = t2;
  }

	public final boolean equals(Object o) {
		 ThreadInfoPair that = (ThreadInfoPair) o;
		 boolean result = false;
		 if(   Misc.equal(this.t1.getName(), that.t1.getName()) && Misc.equal(this.t2.getName(), that.t2.getName())
				|| Misc.equal(this.t1.getName(), that.t2.getName()) && Misc.equal(this.t2.getName(), that.t1.getName())){
			 result = true;
		 }
	   return result;
	  }
	  
	  public final int hashCode() {
	    return t1.getName().hashCode() + t2.getName().hashCode();
	  }
	
}
